package com.guoxin.chapter4.reentractlock.fairnofairtest;

public class RunFair {

	public static void main(String[] args) {
		// 非公平锁的运行结果基本上是乱序的，说明先start()启动的线程不代表县获得锁
		Service service = new Service(false);
		Runnable runnable = new  Runnable() {
			public void run() {
				System.out.println("★ 线程"+Thread.currentThread().getName()+" 运行了");
				service.serviceMethod();
			}
		};
		Thread [] threads = new Thread[10];
		for(int i=0;i<10;i++){
			threads[i] = new Thread(runnable);
		}
		
		for(int i=0;i<10;i++){
			threads[i].start();
		}
	}

}
